package com.wcarmon.life.command{

    import com.adobe.cairngorm.commands.ICommand
    import com.adobe.cairngorm.control.CairngormEvent;
	import mx.controls.Alert;
	import mx.rpc.events.ResultEvent;
	import mx.rpc.events.FaultEvent;
	import mx.rpc.IResponder;
	import com.wcarmon.life.model.LifeModelLocator;
	import com.wcarmon.life.business.UpdateStatsDelegate;
	import com.wcarmon.life.vo.StatsVO;
	import mx.utils.ObjectUtil;
	import flash.utils.*;
	
	
	public class UpdateStatsCommand implements ICommand, IResponder {
		include "../../includes/loggerSnippet.as";
			
		public function execute( event : CairngormEvent ) : void { 
			LifeModelLocator.getInstance().statsAreLoaded = false;
			( new UpdateStatsDelegate(this) ).update();
		}
	
	 	public function result( event : Object ) : void {
			var e : ResultEvent = ResultEvent(event);
			var model : LifeModelLocator = LifeModelLocator.getInstance();
			model.stats = StatsVO.makeStatsVO( e.result );
			model.statsAreLoaded = true;
		}
	
		public function fault( event : Object ) : void {
			include "includes/FaultSnippet.as";
		}
	}
}